package Infix2RPM.processor.infixElement;

import Infix2RPM.processor.Stack.*;
import Infix2RPM.processor.Exception.*;

public class Operator implements BasicOperand {
	private String value = null;

	public Operator(String value) {
		this.value = value;
	}

	public BasicOperand add(BasicOperand operand) throws BasicOperandException {
		throw new BasicOperandException("Syntax error, extra operand '"
				+ operand.getValueAsString() + "' seen next to " + this.value,
				this.className());
	}

	public BasicOperand subtract(BasicOperand operand)
			throws BasicOperandException {
		throw new BasicOperandException("Syntax error, extra operator '"
				+ operand.getValueAsString() + "' seen next to " + this.value,
				this.className());
	}

	public BasicOperand divide(BasicOperand operand)
			throws BasicOperandException {
		throw new BasicOperandException("Syntax error, extra operator '"
				+ operand.getValueAsString() + "' seen next to " + this.value,
				this.className());
	}

	public BasicOperand multiply(BasicOperand operand)
			throws BasicOperandException {
		throw new BasicOperandException("Syntax error, extra operator '"
				+ operand.getValueAsString() + "' seen next to " + this.value,
				this.className());
	}

	public BasicOperand power(BasicOperand operand)
			throws BasicOperandException {
		throw new BasicOperandException("Syntax error, extra operator '"
				+ operand.getValueAsString() + "' seen next to " + this.value,
				this.className());
	}

	public BasicOperand concat(BasicOperand operand)
			throws BasicOperandException {
		throw new BasicOperandException(
				"Syntax error, extra operator seen next to " + this.value,
				this.className());
	}

	public BasicOperand mod(BasicOperand operator) throws BasicOperandException {
		throw new BasicOperandException("Syntax error, extra operator '"
				+ operator.getValueAsString() + "' seen next to " + this.value,
				this.className());
	}
	
	public BooleanOperand equal(BasicOperand operator)
			throws BasicOperandException {
		throw new BasicOperandException("Syntax error, extra operator '"
				+ operator.getValueAsString() + "' seen next to " + this.value,
				this.className());
	}

	public BooleanOperand lessThan(BasicOperand operator)
			throws BasicOperandException {
		throw new BasicOperandException("Syntax error, extra operator '"
				+ operator.getValueAsString() + "' seen next to " + this.value,
				this.className());
	}

	public BooleanOperand lessThanEqual(BasicOperand operator)
			throws BasicOperandException {
		throw new BasicOperandException("Syntax error, extra operator '"
				+ operator.getValueAsString() + "' seen next to " + this.value,
				this.className());
	}

	public BooleanOperand greaterThan(BasicOperand operator)
			throws BasicOperandException {
		throw new BasicOperandException("Syntax error, extra operator '"
				+ operator + "' seen next to " + this.value,
				this.className());
	}

	public BooleanOperand greaterThanEqual(BasicOperand operator)
			throws BasicOperandException {
		throw new BasicOperandException("Syntax error, extra operator '"
				+ operator.getValueAsString() + "' seen next to " + this.value,
				this.className());
	}


	public BooleanOperand or(BasicOperand operand) throws LogicException {
		throw new BasicOperatorException(
				"Logical OR next to an operator is unsupported", this.className());
	}

	public BooleanOperand and(BasicOperand operand) throws LogicException {
		throw new BasicOperatorException(
				"logical AND next to an operator is unsupported", this.className());
	}
	
	public boolean isNull() {
		return this.value == null;
	}

	public boolean isEqual(String token) {
		return this.value.equals(token);
	}

	public boolean isEmpty() {
		return this.equals("");
	}

	public Object getValue() {
		return this.value;
	}
	
	public String getValueAsString() {
		return this.value.toString();
	}

	private String className() {
		return this.getClass().getName();
	}
}
